#include <bits/stdc++.h>
using namespace std;
#define int long long
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
    return x*f;
}
const int N=160,K=12;
int n,m,ans,cnt;
struct name{
    int c,t,w;
    bool operator <(const name a)const{
        return w*a.t>a.w*t;
    }
}a[N],b[N];
int f[N*N*N];
signed main(){
    freopen("book.in","r",stdin);
    freopen("book.out","w",stdout);
    n=read();
    for(int i=1;i<=n;i++) a[i].c=read();
    for(int i=1;i<=n;i++) a[i].t=read();
    for(int i=1;i<=n;i++) a[i].w=read();
    m=read();
    sort(a+1,a+n+1);
    // for(int i=1;i<=n;i++) cout<<a[i].c<<" "<<a[i].t<<" "<<a[i].w<<"\n";
    memset(f,-0x3f,sizeof(f));
    int x=1;
    while(x<=n&&80*80*80<=m-a[x].c*a[x].t) m-=a[1].c*a[1].t,ans+=a[1].c*a[1].w,a[1].c=0,x++;
    if(m>80*80*80)
        for(int i=a[x].c;i;i--){
            if(m-(i-1)*a[x].t<80*80*80){
                ans+=i*a[x].w;
                m-=i*a[x].t;
                a[x].c-=i;
                break;
            }
        }
    // cout<<ans<<" "<<x<<" "<<a[x].c<<"\n";
    f[m]=ans;
    // cout<<"\n";
    for(int i=1;i<=n;i++){
        // for(int j=1;j<=a[i].c;j++) b[++cnt]={1,a[i].t,a[i].w};
        for(int j=0;j<=K;j++)
            if(a[i].c>=(1<<j)) b[++cnt]={1<<j,a[i].t<<j,a[i].w<<j},a[i].c-=(1<<j);
        if(a[i].c) b[++cnt]={a[i].c,a[i].c*a[i].t,a[i].c*a[i].w};
    }
    if(cnt==0){
        cout<<ans;
        return 0;
    }
    // for(int i=1;i<=cnt;i++) cout<<b[i].c<<" "<<b[i].t<<" "<<b[i].w<<'\n';
    for(int i=1;i<=cnt;i++)
        for(int j=b[i].t;j<=m;j++)
            f[j-b[i].t]=max(f[j-b[i].t],f[j]+b[i].w);
    for(int i=0;i<=m;i++) ans=max(ans,f[i]);
    cout<<ans;
    return 0;
}